<?php
/*
 * $id:admin/includes/classes/productImageHandlerTpl.inc
 *
 * oscProductImage version 2.0
 *
 * Copyright 2011, Zaenal Muttaqin
 * http://blog.lokamaya.net - http://lokamaya.com
 *
 * Licensed under the MIT license:
 * http://creativecommons.org/licenses/MIT/
 *
 */
 
 $directory_privileges = explode(',', OSC_PRODUCT_IMAGE_DIRECTORY_PRIVILEGE);
 $delete_privileges = explode(',', OSC_PRODUCT_IMAGE_DELETE_PRIVILEGE);
  
 $has_directory_privileges = tep_not_null($directory_privileges) ? (in_array($admin['id'], $directory_privileges) ? 1 : 0) : 1;
 $has_delete_privileges = tep_not_null($delete_privileges) ? (in_array($admin['id'], $delete_privileges) ? 1 : 0) : 1;
 $catalog_image = tep_catalog_href_link(substr(DIR_WS_CATALOG_IMAGES, 1));
?>
<div id="opiContainer" style="position:relative">
  <!--help dialog-->
  <div id="opiHelpDialog" class="opiDialog" title="<?php echo OPI_DIALOG_HELP; ?>">
    <div class="content">
    <h2><?php echo OPI_TITLE; ?><br /><small><a href="http://blog.lokamaya.net" target="_blank">By: zaenal/lokamaya</a></small></h2>
      <?php echo OPI_HELP_TEXT; ?>
    </div>
  </div>
  
  <!--upload dialog-->
  
  <div id="opiUploadDialog" class="opiDialog" title="<?php echo OPI_DIALOG_UPLOAD; ?>">
    <div class="content"><div class="contentWrap">
      <form name="opiUploadForm" action="<?php echo tep_href_link('opi_productimage.php', 'action=upload'); ?>" method="post" target="opiUploadFrame" enctype="multipart/form-data">
          <input type="hidden" name="opi_rename" value="" />
          
          <div class="dlLeft"><ul id="uploadPreview">
            <li id="uploadPreviewImage">
              <span><?php echo OPI_LABEL_IMAGE_PREVIEW; ?></span>
            </li>
            <li id="uploadPreviewInfo">-</li>
          </ul></div>
          
          <div class="dlRight"><dl class="dlcentered">
            <dt><?php echo OPI_HEADER_DIRECTORY; ?></dt>
            <dd>
              <select name="opi_folder" id="opi_folder_upload" title="<?php echo OPI_LABEL_DIRECTORY; ?>"></select>
            </dd>
            <dt><?php echo OPI_HEADER_FILE; ?></dt>
            <dd>
              <input type="file" accept="image/*" name="opi_upload" id="opi_upload" title="<?php echo OPI_LABEL_FILE; ?>" />
            </dd>
            <dd><table border="0" cellspacing="0" cellpadding="0">
              <tr><td><input type="checkbox" name="opi_auto_rename" id="opi_auto_rename" value="1" checked="checked" title="<?php echo OPI_LABEL_RENAME; ?>" /></td><td><label for="opi_auto_rename"><?php echo OPI_LABEL_RENAME; ?></label></td></tr>
            </table></dd>
          </dl>
          <div class="loader"><span></span></div></div>
      </form>
    </div></div>
  </div>

  <!--create directory dialog-->
  
  <div id="opiDirectoryDialog" class="opiDialog" title="<?php echo OPI_DIALOG_DIRECTORY; ?>">
    <div class="content"><div class="contentWrap">
      <form action="<?php echo tep_href_link('opi_productimage.php', 'action=createDirectory'); ?>" method="post" name="opiDirectoryForm">
          <br /><br /><dl class="dlcentered">
            <dt><?php echo OPI_HEADER_DIRECTORY; ?></dt>
            <dd>
              <select name="opi_folder" id="opi_folder_new" title="<?php echo OPI_LABEL_DIRECTORY; ?>"></select>
            </dd>
            <dt><?php echo OPI_HEADER_DIRECTORY_NEW; ?></dt>
            <dd>
              <input type="text" name="opi_directory" id="opi_directory" title="<?php echo OPI_LABEL_DIRECTORY_NEW; ?>" />
            </dd>
          </dl>
      </form>
      <div class="loader"><span></span></div>
    </div></div>
  </div>  
  
  <!--browse dialog-->
  
  <div id="opiBrowseDialog" class="opiDialog" title="<?php echo OPI_DIALOG_BROWSE; ?>">
    <div class="content"><div class="contentWrap">
      <form action="<?php echo tep_href_link('opi_productimage.php', 'action=browseFiles'); ?>" method="post" name="opiBrowseForm"><input type="hidden" name="page" id="opi_page_browse" value="1" />
          <dl class="dlcentered">
            <dd>
              <select name="opi_folder" id="opi_folder_browse" title="<?php echo OPI_LABEL_DIRECTORY; ?>"></select>
            </dd>
          </dl>
          <div style="clear:both"></div>
      </form>
      <div class="loader"><span></span></div>
      <div>
        <ul id="opiImageBrowse" class="opiImageListing"></ul>
        <div style="clear:both"></div>
      </div>
    </div></div>
  </div>
</div>
<script type="text/javascript">
<!--
var oscProductImageHelper = {
  sessionLife: <?php echo OPI_HELPER_SESSION_LIFE; ?>, 
  cleanup: <?php echo OSC_PRODUCT_IMAGE_CLEANUP; ?>, 
  ajaxURL: '<?php echo tep_href_link('opi_productimage.php'); ?>',
<?php  
if (OSC_PRODUCT_IMAGE_MODREWRITE=='false') {
  echo '  '."imageURL: {path:'" . OPI_HELPER_CATALOG_IMAGES . "', relative:'" . OPI_HELPER_RELATIVE_DIR . "', medium:'" . tep_catalog_href_link('opi_thumbnail.php', 'def=adminpreview&file=') . "', small:'" . tep_catalog_href_link('opi_thumbnail.php', 'def=adminthumb&file=') . "', transparent:'images/pixel_trans.gif'},\n";
} else {
  echo '  '."imageURL: {path:'" . OPI_HELPER_CATALOG_IMAGES . "', relative:'" . OPI_HELPER_RELATIVE_DIR . "', medium:'" . OPI_HELPER_CATALOG_IMAGES . "thumbs/def/adminpreview/', small:'" . OPI_HELPER_CATALOG_IMAGES . "thumbs/def/adminthumb/', transparent:'images/pixel_trans.gif'},\n";
}
?>
  privileges: {directory:<?php echo OPI_HELPER_DIR_PRIVILEGE; ?>,deletes:<?php echo OPI_HELPER_DEL_PRIVILEGE; ?>},
  language_id:'<?php echo OPI_HELPER_LANGUAGE_ID; ?>',
  products_images: '<?php echo OPI_HELPER_PRODUCTS_IMAGES; ?>',
  allowedExtensions: '<?php echo OPI_HELPER_ALLOWED_EXT; ?>',
  buttons: {<?php echo OPI_BUTTONS_OBJECT; ?>},
  labels: {<?php echo OPI_LABELS_OBJECT; ?>},
  messages: {<?php echo OPI_MESSAGES_OBJECT; ?>}
};
//-->
</script>
<link rel="stylesheet" type="text/css" href="<?php echo tep_catalog_href_link('ext/jquery/plugins/jquery.oscProductImage.css'); ?>"></link>
<script type="text/javascript" src="<?php echo tep_catalog_href_link('ext/jquery/plugins/jquery.oscProductImage.js'); ?>"></script>

